package di_login;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Manager implements User {
	String id;
	String pwd;
	MyDB db;
	Connection conn;

	public boolean login(String id, String pwd) {
		boolean flag = false;
		conn = db.getConnection();
		String sql = "select * from student where mid = ? and pwd=? ";
		try {
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, id);
			pstmt.setString(2, pwd);

			ResultSet rs = pstmt.executeQuery();
			if (rs.next())
				flag = true;
			rs.close();
			pstmt.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			return flag;

		}
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public MyDB getDb() {
		return db;
	}

	public void setDb(MyDB db) {
		this.db = db;
	}

	public Connection getConn() {
		return conn;
	}

	public void setConn(Connection conn) {
		this.conn = conn;
	}

}
